package com.manner.groupon.model.vo;

import com.manner.groupon.model.entity.GrouponCoupons;
import com.manner.groupon.model.entity.Store;

import java.text.NumberFormat;
import java.util.List;

/**
 * 返回给前端页面的商品数据
 */
public class StoreVo extends Store {

    /**
     * 距离
     */
    private double distance;

    /**
     * 团购券
     */
    private List<GrouponCoupons> list;

    private String unit;

    private String linkPhone;


    public StoreVo(Store store, double distance, List<GrouponCoupons> list, String linkPhone) {
        super(
                store.getId(),
                store.getStoreNo(),
                store.getAdminId(),
                store.getName(),
                store.getHours(),
                store.getImg(),
                store.getAddress(),
                store.getTypeId(),
                store.getLatitude(),
                store.getLongitude(),
                store.getLabel(),
                store.getScale(),
                store.getStatus(),
                store.getNumberOfVisitors(),
                store.getIsDelete(),
                store.getCreateTime(),
                store.getUpdateTime()
        );
        NumberFormat numberFormat = NumberFormat.getInstance();
        numberFormat.setMaximumFractionDigits(2);
        //判断是否大于1000米
        if (distance > 1000) {
            //除
            distance = distance / 1000;

            this.unit = "km";
        } else {
            this.unit = "m";
        }
        this.distance = Double.valueOf(numberFormat.format(distance));
        this.list = list;
        this.linkPhone = linkPhone;
    }

    public List<GrouponCoupons> getList() {
        return list;
    }

    public void setList(List<GrouponCoupons> list) {
        this.list = list;
    }

    public double getDistance() {
        return distance;
    }

    public void setDistance(double distance) {
        this.distance = distance;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getLinkPhone() {
        return linkPhone;
    }

    public void setLinkPhone(String linkPhone) {
        this.linkPhone = linkPhone;
    }
}
